<?php
namespace app\kucun\model;

use think\Model;

class ProductModel extends Model{

    protected $table = 'kucun_product';
    protected $pk = 'id';

    public function category(){
        return $this->hasOne(CategoryModel::class,'id','catgory_id');
    }

    public function stock(){
        return $this->hasMany(ProductStockModel::class,'product_id','id');
    }

    // public function shopStock(){
    //     return $this->hasMany(ProductStockModel::class,'product_id','id')->where(['status' => 1])->group("product_id, shop_id")->with(['shop'])->field("product_id, shop_id,count(id) as stock_num");
    // }

}